package cn.jzq.kotoba.modules.designpattern.demo.demo1;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Objects;

/**
 * @author jzq
 * @date 2018/12/21 16:04
 */
public class Test2 {

    public static void main(String[] args) {

        long start = System.currentTimeMillis();
        for (int x = 10; x > 0; x--) {
            List<Node> nodes = new ArrayList<>();
            for (int i = 1; i < 10000; i++) {
                Node node = new Node();
                node.setId(i);
                nodes.add(node);
            }
            Collections.shuffle(nodes);

            for (int i = 1; i < 10000; i++) {
                Integer j = i;
                Node node = nodes.stream()
                        .filter(n -> Objects.equals(n.getId(), j))
                        .findFirst()
                        .orElse(null);
                if (node != null) {
//                System.out.println(node.getId());
//                    nodes.remove(node);
                }
            }
        }
        long end = System.currentTimeMillis();
        System.out.println((end - start)/ 10);


    }
}
